#include "XmlIssuerMessageHandler.h"

XmlIssuerMessageHandler::XmlIssuerMessageHandler(void)
{
	type = Constant::IssuerMessage;
}
XmlIssuerMessageHandler::~XmlIssuerMessageHandler(void)
{
}
XmlIssuerMessageHandler::XmlIssuerMessageHandler(int client, int windowsService, int mobile) {
	clientId = client;
	windowsServiceId = windowsService;
	mobileId = mobile;
	type = Constant::IssuerMessage;
}
XmlIssuerMessageHandler::XmlIssuerMessageHandler(char* xmlString) : XmlHandler(xmlString) {
	type = Constant::IssuerMessage;
	TiXmlElement* clientNode = rootNode->FirstChildElement("ClientId");
	clientId = atoi(clientNode->GetText());

	TiXmlElement* windowsServiceNode = rootNode->FirstChildElement("WindowsServiceId");
	windowsServiceId = atoi(windowsServiceNode->GetText());

	TiXmlElement* mobileNode = rootNode->FirstChildElement("MobileId");
	mobileId = atoi(mobileNode->GetText());

}
void XmlIssuerMessageHandler::addAttributeType() {	
	rootNode->SetAttribute("type", Constant::IssuerMessage);
}

void XmlIssuerMessageHandler::addBody() {
	char buffer[100];
	_itoa_s(clientId, buffer, 100, 10);
	TiXmlElement* clientNode = new TiXmlElement("ClientId");	
	clientNode->InsertEndChild(*(new TiXmlText(buffer)));
	rootNode->InsertEndChild(*clientNode);

	char buffer2[100];
	_itoa_s(windowsServiceId, buffer2, 100, 10);
	TiXmlElement* wsNode = new TiXmlElement("WindowsServiceId");	
	wsNode->InsertEndChild(*(new TiXmlText(buffer2)));
	rootNode->InsertEndChild(*wsNode);

	char buffer3[100];
	_itoa_s(mobileId, buffer3, 100, 10);
	TiXmlElement* mobileNode = new TiXmlElement("MobileId");	
	mobileNode->InsertEndChild(*(new TiXmlText(buffer3)));
	rootNode->InsertEndChild(*mobileNode);

}